<div class="maintop">
    当前位置：概率用户管理
    <a href="javascript:;" action="<?=$basepath?>_add" class="mainFrame button icon-plus">添加用户</a>
    <a href="javascript:;" action="<?=$basepath?>?<?=$this->page_url($searchdata['page_current'],$page_url)?>" id="btn_refresh" class="mainFrame button">刷新</a>
    <? if(ISDEBUG){ ?>
        <a href="javascript:$('.debuginfo').toggle();" class="button">调试信息</a>
    <? } ?>
    <a href="/cache/update?key=<?=$this->redisPrefix['UPLIST']?>" class="button" target="ajax" func="loadpage">更新缓存</a>
</div>
<div class="main-search">
    <table width="100%">
        <tbody><tr>
            <td>
                <form action="<?=$basepath?>" id="SearchForm" method="get" target="ajax" dataType="html" onajax="beforeSearchForm" call="searchForm" container="#iframe" isLoad="true">
                    用户编号：
                    <input type="text" id="sKey" name="sKey" class="int" placeholder="搜索关键字">
                    <select name="usertype">
                        <option value="">全部</option>
                        <? foreach ($this->usertype as $k=>$v){ ?>
                            <option value="<?=$k?>"><?=$v?></option>
                        <? } ?>
                    </select>
                    加入日期：从
                    <input id="fromTime" name="fromTime" type="text" class='Wdate' style='width:100px;' value="<?=$searchdata['fromTime']?date('Y-m-d',intval(strtotime($searchdata['fromTime']))):''?>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})"></input>&nbsp;至
                    <input id="toTime" name="toTime" type="text" class='Wdate' style='width:100px;' value="<?=$searchdata['toTime']?date('Y-m-d',intval(strtotime($searchdata['toTime']))):''?>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})"></input>&nbsp;&nbsp;
                    <input type="submit" value="搜索" class="upbutton">
                    每页：
                    <select id="ps" name="ps">
                        <option value="12" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 12) echo 'selected';?> >12</option>
                        <option value="20" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 20) echo 'selected';?> >20</option>
                        <option value="30" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 30) echo 'selected';?> >30</option>
                        <option value="50" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 50) echo 'selected';?> >50</option>
                        <option value="100" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 100) echo 'selected';?> >100</option>
                    </select>
                    <input action="<?=$basepath?>_delete_list" type="button" id="deleteSelectId" value="删除选择" class="upbutton">
                </form>
            </td>
        </tr>
        </tbody>

    </table>
</div>
<div id="mainbody">
    <table width="100%" class="tablist">
        <tr class="trbg"><th width="30"><input id="selectAllid" type="checkbox" value="1" /></th>
            <th>No.</th>
            <th>充</th>
            <th>玩家号码</th>
            <th>玩家昵称</th>
            <th>类型</th>
            <th>帐户余额</th>
            <th>参与金额</th>
            <th>充值</th>
            <th>提现</th>
            <th>加入时间</th>
            <th>有效时长</th>
            <th>状态</th>
            <th title="按用户充值总额的比例">盈亏概率</th>
            <th><a href="javasciipt:;" action="<?=$basepath?>?<?=($searchdata['sorttype']=='DESC' ? str_replace('DESC','ASC',$this->page_url(1,$page_url)) : str_replace('ASC','DESC',$this->page_url(1,$page_url)))?>" class="mainFrame">盈亏</a></th>
            <th width="60">操作</th>
        </tr>
        <? foreach($datas as $v){
            //$sql = "SELECT IFNULL(SUM(betcoin),0) AS _betcoin,IFNULL(SUM(profit),0) AS _profit FROM rp_betslog WHERE state=1 AND uid=".$v['uid'];
            //$_profit = $this->db->query($sql,2);
            if(((time() - $v['jointime']) < $v['effectivetime'])){
                $isEffective = '有效';
                $isEffectiveColor = '';
            }else{
                $isEffective = '失效';
                $isEffectiveColor = 'red';
            }

            ?>
            <tr>
                <td width="30"><input type="checkbox" name="selectValue" value="<?=$v['uid']?>" /></td>
                <td><a href="javascript:;" action="/box/mail_add_pop?touid=<?=$v['uid']?>" class="mainFrame" title="发送站内信"><?=$v['uid']?></a></td>
                <td width="20"><a href="/members/rechargetouser?uno=<?=$v['uno']?>" class="button fa fa-cny" target="ajax" func="loadpage" title="给玩家充值"></a></td>
                <td><a href="/members/members_list_edit?uid=<?=$v['uid']?>" class="colorbox"><?=$v['uno']?></a></td>
                <td style="text-align:left"><?=$v['nickname']?></td>
                <td><?=$this->usertype[$v['usertype']]?></td>
                <td style="text-align:right"><?=($v['coin'] <= 0 ? '' : $v['coin'])?></td>
                <td style="text-align:right"><?=($v['betcoin'] <= 0 ? '' : $v['betcoin'])?></td>
                <td style="text-align:right"><?=(($v['rechargecoin'] <= 0) ? '' : $v['rechargecoin'])?></td>
                <td style="text-align:right"><?=(($v['cashcoin'] <= 0) ? '' : $v['cashcoin'])?></td>
                <td><?=date('Y-m-d H:i:s', $v['jointime'])?></td>
                <td><?=$v['effectivetime']?>s</td>
                <td class="<?=$isEffectiveColor?>" style="text-align: center"><?=$isEffective?></td>
                <td><?=$v['winpoints']?>%</td>
                <td class="<?=($v['profit']>0 ? "red" : "green")?>"><?=($v['profit'] == 0 ? '' : $v['profit'])?></td>
                <td>
                    <? if($v['isdelete']){ ?>
                        <a action="<?=$basepath?>_recovery?uid=<?=$v['uid']?>" title="恢复" class="mainFrame button icon-undo" href="javascript:;"></a>
                    <? }else{ ?>
                        <a action="<?=$basepath?>_delete?uid=<?=$v['uid']?>" title="删除" class="mainFrame button icon-trash-2" href="javascript:;"></a>
                    <? } ?>
                    <a action="<?=$basepath?>_edit?uid=<?=$v['uid']?>" title="编辑" class="mainFrame button icon-edit" href="javascript:;"></a>
                </td>
            </tr>
        <? } ?>
    </table>
    <? require VIEW.'/page.view.php' ?>
</div>
<script type="text/javascript">
    function beforeSearchForm(){

    }
    function searchForm(self, _html, data){
        $("#iframe").html(_html);
    }
    $(document).ready(function(){
        <?php
        if(!empty($searchdata['sKey'])){
            echo '$("#sKey").val("'.$searchdata['sKey'].'");';
        }
        if(!empty($searchdata['usertype'])){
            echo '$("select[name=\'usertype\'] option[value=\''.$searchdata['usertype'].'\']").attr("selected", "selected");';
        }
        ?>
        $(".colorbox").colorbox({ iframe: true,width:"80%",height:"80%" });
    });
</script>
